package com.ls.userlog.Inteceptor;

import com.ls.userlog.service.UserOperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class RequestUrlInteceptor implements HandlerInterceptor {

    @Autowired
    private UserOperateLogService userOperateLogService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Integer result = userOperateLogService.insert(request);
        if(result > 0){
            log.info("保存用户操作日志成功");
        }
        return true;
    }
}
